package com.city.ajax.pub;

import com.city.domain.city.*;
import com.city.domain.economic.EconomicType;
import com.city.domain.economic.EnterpriseAffiliation;
import com.city.domain.economic.EnterpriseRegulatoryClassification;
import com.city.domain.economic.EnterpriseScale;
import com.city.domain.pub.*;
import com.city.repository.pub.PubFilepathRepository;
import com.city.service.city.*;
import com.city.service.economic.EconomicTypeService;
import com.city.service.economic.EnterpriseAffiliationService;
import com.city.service.economic.EnterpriseRegulatoryClassificationService;
import com.city.service.economic.EnterpriseScaleService;
import com.city.service.pub.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.query.Param;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @deprecation: 公共分组接口
 * @dmail: 398521613@qq.com
 * @author: L-H
 * @date: 2018-07-20 16:32
 */
@RequestMapping("/ajax/pub")
@RestController
public class PubClassAjax {

    @Autowired
    private PubProvinceService provinceService;

    @Autowired
    private PubCityService cityService;

    @Autowired
    private PubCountyService countyService;

    @Autowired
    private CityTownService townService;

    @Autowired
    private CityVillageService villageService;

    @Autowired
    private CityCopnoteMaincontentService copnoteMaincontentService;

    @Autowired
    private CityCopnoteObjectService copnoteObjectService;

    @Autowired
    private CityEventCountMethodService eventCountMethodService;

    @Autowired
    private CityEventSrcnameService eventSrcnameService;

    @Autowired
    private CityEventTypeService eventTypeService;

    @Autowired
    private EconomicTypeService economicTypeService;

    @Autowired
    private EnterpriseAffiliationService affiliationService;

    @Autowired
    private EnterpriseRegulatoryClassificationService classificationService;

    @Autowired
    private EnterpriseScaleService scaleService;

    @Autowired
    private PubFiletypeService filetypeService;

    @Autowired
    private PubHouseUseService houseUseService;

    @Autowired
    private PubHouseUsebuildService houseUsebuildService;

    @Autowired
    private PubHouseStructureService houseStructureService;

    @Autowired
    private PubHouseFromService houseFromService;

    @Autowired
    private PubLandCoucherService landCoucherService;

    @Autowired
    private PubLandGetService landGetService;

    @Autowired
    private PubNationCategoryService nationCategoryService;

    @Autowired
    private PubEducationDegreeService educationDegreeService;

    @Autowired
    private PubFilepathRepository pubFilepathRepository;


    /**
     * @deprecation: 根据国家编码获取省份
     * @dmail: 398521613@qq.com
     * @author: L-H
     * @param code 国家代号
     * @date: 2018-07-20 16:32
     */
    @RequestMapping("/getprovince")
    @ResponseBody
    public List<PubProvince> findPubProvinceCode(@RequestParam(value = "code") String code){
        return provinceService.findCode();
    }

    /**
     * @deprecation: 根据省份编码获取城市信息
     * @dmail: 398521613@qq.com
     * @author: L-H
     * @param code 省份代号
     * @date: 2018-07-20 16:32
     */
    @RequestMapping("/getcity")
    @ResponseBody
    public List<PubCity> findPubCityCode(@RequestParam(value = "code") String code){
        return cityService.findCode(code);
    }

    /**
     * @deprecation: 根据城市编码获取县区信息
     * @dmail: 398521613@qq.com
     * @author: L-H
     * @param code 市代号
     * @date: 2018-07-20 16:32
     */
    @RequestMapping("/getcounty")
    @ResponseBody
    public List<PubCounty> findPubCountyCode(@RequestParam(value = "code") String code){
        return countyService.findCode(code);
    }


    /**
     * @deprecation: 根据县区编码获取镇乡信息
     * @dmail: 398521613@qq.com
     * @author: L-H
     * @param code 县区代号
     * @date: 2018-07-20 16:32
     */
    @RequestMapping("/gettown")
    @ResponseBody
    public List<CityTown> findCityTownCode(@RequestParam(value = "code") String code){
        return townService.findName(code);
    }

    /**
     * @deprecation: 根据乡镇编码获取街道和村的信息
     * @dmail: 398521613@qq.com
     * @author: L-H
     * @param code 镇主键id
     * @date: 2018-07-20 16:32
     */
    @RequestMapping("/getvillage")
    @ResponseBody
    public List<CityVillage> findCityVillageCode(@RequestParam(value = "code") Integer code){
        return villageService.findName(code);
    }

    /**
     * @deprecation: 获取民情日记主要内容分类信息
     * @dmail: 398521613@qq.com
     * @author: L-H
     * @date: 2018-07-20 16:32
     */
    @RequestMapping("/getcopnote-maincontent")
    @ResponseBody
    public List<CityCopnoteMaincontent> findCityCopnoteMaincontentCode(){
        return copnoteMaincontentService.getAll();
    }

    /**
     * @deprecation: 获取民情日记走访对象分类信息
     * @dmail: 398521613@qq.com
     * @author: L-H
     * @date: 2018-07-20 16:32
     */
    @RequestMapping("/getcopnote-object")
    @ResponseBody
    public List<CityCopnoteObject> findCityCopnoteObjectCode(){
        return copnoteObjectService.getAll();
    }

    /**
     * @deprecation: 获取统计计算公式
     * @dmail: 398521613@qq.com
     * @author: L-H
     * @date: 2018-07-20 16:32
     */
    @RequestMapping("/getevent-count-method")
    @ResponseBody
    public List<CityEventCountMethod> findCityEventCountMethodCode(){
        return eventCountMethodService.getAll();
    }

    /**
     * @deprecation: 获取所有的上报方式
     * @dmail: 398521613@qq.com
     * @author: L-H
     * @date: 2018-07-20 16:32
     */
    @RequestMapping("/getevent-srcname")
    @ResponseBody
    public List<CityEventSrcname> findCityEventSrcnameCode(){
        return eventSrcnameService.getAll();
    }

    /**
     * @deprecation: 获取案件分类信息
     * @dmail: 398521613@qq.com
     * @author: L-H
     * @param typeClass 分类级别
     * @date: 2018-07-20 16:32
     */
    @RequestMapping("/getevent-type")
    @ResponseBody
    public List<CityEventType> findCityEventTypeCode(@RequestParam(value = "typeClass") int typeClass){
        return eventTypeService.findAllByTypeClass(typeClass);
    }

    /**
     * @deprecation: 获取企业规模分类
     * @dmail: 398521613@qq.com
     * @author: L-H
     * @date: 2018-07-20 16:32
     */
    @RequestMapping("/getenterprise-scale")
    @ResponseBody
    public List<EnterpriseScale> findEnterpriseScaleAll(){
        return scaleService.getAll();
    }

    /**
     * @deprecation: 获取监管分类信息
     * @dmail: 398521613@qq.com
     * @author: L-H
     * @date: 2018-07-20 16:32
     */
    @RequestMapping("/getenterprise-classification")
    @ResponseBody
    public List<EnterpriseRegulatoryClassification> findEnterpriseRegulatoryClassificationAll(){
        return classificationService.getAll();
    }

    /**
     * @deprecation: 获取隶属关系分类信息
     * @dmail: 398521613@qq.com
     * @author: L-H
     * @date: 2018-07-20 16:32
     */
    @RequestMapping("/getenterprise-affiliation")
    @ResponseBody
    public List<EnterpriseAffiliation> findEnterpriseAffiliationAll(){
        return affiliationService.getAll();
    }

    /**
     * @deprecation: 获取企业经济类型信息
     * @dmail: 398521613@qq.com
     * @author: L-H
     * @date: 2018-07-20 16:32
     */
    @RequestMapping("/geteconomic-type")
    @ResponseBody
    public List<EconomicType> findEconomicTypeAll(){
        return economicTypeService.getAll();
    }

    /**
     * @deprecation: 获取允许上传的所有文件类型
     * @dmail: 398521613@qq.com
     * @author: L-H
     * @date: 2018-07-20 16:32
     */
    @RequestMapping("/getfile-type")
    @ResponseBody
    public List<PubFiletype> findFilepathAll(){
        return filetypeService.getAll();
    }

    /**
     * @deprecation: 获取房屋建筑用途分类信息
     * @dmail: 398521613@qq.com
     * @author: L-H
     * @date: 2018-07-20 16:32
     */
    @RequestMapping("/gethouse-from")
    @ResponseBody
    public List<PubHouseFrom> findPubHouseFromAll(){
        return houseFromService.getAll();
    }

    /**
     * @deprecation: 获取房屋用途分类信息
     * @dmail: 398521613@qq.com
     * @author: L-H
     * @date: 2018-07-20 16:32
     */
    @RequestMapping("/gethouse-use")
    @ResponseBody
    public List<PubHouseUse> findPubHouseUseAll(){
        return houseUseService.getAll();
    }

    /**
     * @deprecation: 获取建筑物用途分类信息
     * @dmail: 398521613@qq.com
     * @author: L-H
     * @date: 2018-07-20 16:32
     */
    @RequestMapping("/gethouse-usebuild")
    @ResponseBody
    public List<PubHouseUsebuild> findPubHouseUsebuildAll(){
        return houseUsebuildService.getAll();
    }

    /**
     * @deprecation: 获取房屋结构分类信息
     * @dmail: 398521613@qq.com
     * @author: L-H
     * @date: 2018-07-20 16:32
     */
    @RequestMapping("/gethouse-structure")
    @ResponseBody
    public List<PubHouseStructure> findPubHouseStructureAll(){
        return houseStructureService.getAll();
    }

    /**
     * @deprecation: 获取土地获取方式分类信息
     * @dmail: 398521613@qq.com
     * @author: L-H
     * @date: 2018-07-20 16:32
     */
    @RequestMapping("/getland-get")
    @ResponseBody
    public List<PubLandGet> findPubLandGetAll(){
        return landGetService.getAll();
    }

    /**
     * @deprecation: 获取土地凭证分类信息
     * @dmail: 398521613@qq.com
     * @author: L-H
     * @date: 2018-07-20 16:32
     */
    @RequestMapping("/getland-coucher")
    @ResponseBody
    public List<PubLandCoucher> findPubLandCoucherAll(){
        return landCoucherService.getAll();
    }

    /**
            * @deprecation: 获取民族分类信息
     * @dmail: 398521613@qq.com
     * @author: L-H
     * @date: 2018-07-20 16:32
            */
    @PostMapping("/getnation")
    @ResponseBody
    public List<PubNationCategory> findPubNationCategoryAll(){
        return nationCategoryService.getAll();
    }

    /**
     * @deprecation: 获取教育程度分类信息
     * @dmail: 398521613@qq.com
     * @author: L-H
     * @date: 2018-07-20 16:32
     */
    @PostMapping("/geteducation-degree")
    @ResponseBody
    public List<PubEducationDegree> findPubEducationDegreeAll(){
        return educationDegreeService.getAll();
    }

    /**
     * @author  王宇
     * @date 2018/10/10
     * @description  获取所有文件
     */
    @PostMapping("/get-allfile")
    @ResponseBody
    public Map<String,Object> getAllFiles(){
        Map<String,Object> map = new HashMap<>();
        List<PubFilepath> filepathList = pubFilepathRepository.findAll();
        map.put("data",filepathList);
        return map;
    }

    /**
     * @author  王宇
     * @date 2018/10/10
     * @description  通过类型查找文件
     */
    @PostMapping("/get-bytype")
    @ResponseBody
    public Map<String,Object> getFileByType(@Param("type") Integer type){
        Map<String,Object> map = new HashMap<>();
        List<PubFilepath> filepathList = pubFilepathRepository.findByType(type);
        map.put("data",filepathList);
        return map;
    }
}
